﻿package com.bizmlib.utils
{
	import flash.external.ExternalInterface;
	import flash.system.Capabilities;
	import flash.system.ApplicationDomain;


	public function traceExternally(message:*):void
	{
		if(message && !(message is String))
			message = String(message);
		
		//if(ExternalInterface.available && ExternalInterface.objectID)
		if(ExternalInterface.available && ExternalInterface.call("eval", "true")==true)
		{
			ExternalInterface.call("console.log", message);
			return;
		}
		
		var canUseLocalConnection:Boolean = true;
		CONFIG::TEST_LOCAL
		{
			canUseLocalConnection = false;
		}
		
		if(canUseLocalConnection && Capabilities.playerType=="External" && ApplicationDomain.currentDomain.hasDefinition("flash.net.LocalConnection"))
		{
			var lcClass:Class = ApplicationDomain.currentDomain.getDefinition("flash.net.LocalConnection") as Class;
			var lc:Object = new lcClass();
			lc.send("standAloneTracer", "doTrace", message);
		}
		else
			trace(message);
	}
}